package com.nbcio.modules.erp.address.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nbcio.modules.erp.address.entity.UserAddresses;
import com.nbcio.modules.erp.address.service.UserAddressesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.util.Assert;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @ClassName UserAddressController
 * @Description 收货地址接口
 * @date 2024/4/10 10:14
 * @Version 1.0
 */
@Api(tags="收货地址")
@RequestMapping("/sys/userAddress")
@RestController
@Slf4j
public class UserAddressController {

    @Autowired
    private UserAddressesService userAddressesService;


    /**
     * 用户收货地址-添加
     * @param map
     * @return
     */
    @AutoLog(value = "用户收货地址-添加")
    @ApiOperation(value="用户收货地址-添加", notes="用户收货地址-添加")
    @PostMapping("/add")
    public Result<?> add(@RequestBody Map<String,Object> map) {
        userAddressesService.add(map);
        return Result.OK("添加收货地址成功");
    }

    /**
     * 用户收货地址-修改
     * @param map
     * @return
     */
    @AutoLog(value = "用户收货地址-修改")
    @ApiOperation(value="用户收货地址-修改", notes="用户收货地址-修改")
    @PostMapping("/edit")
    public Result<?> edit(@RequestBody Map<String,Object> map) {
        userAddressesService.edit(map);
        return Result.OK("修改手动地址成功");
    }


    /**
     * 用户收货地址-删除
     * @param map
     * @return
     */
    @AutoLog(value = "用户收货地址-删除")
    @ApiOperation(value="用户收货地址-删除", notes="用户收货地址-删除")
    @PostMapping("/delete")
    public Result<?> delete(@RequestBody Map<String,Object> map) {
        userAddressesService.delete(map);
        return Result.OK("删除收货地址成功");
    }

    /**
     * 用户收货地址-查询收货地址
     * @param map
     * @return
     */
    @AutoLog(value = "用户收货地址-查询收货地址")
    @ApiOperation(value="用户收货地址-查询收货地址", notes="用户收货地址-查询收货地址")
    @PostMapping("/query")
    public Result<?> query(@RequestBody Map<String,Object> map) {
        List<UserAddresses> userAddressesList = userAddressesService.query(map);
        return Result.OK(userAddressesList);
   }


}
